﻿using System;
using System.ComponentModel;

namespace WgpgCore
{
    public sealed class Config : INotifyPropertyChanged
    {
        #region Properties

        public String MainWindowWidth
        {
            get { return Data.GetValue("MainWindowWidth", "465"); }
            set { Data.SetValue("MainWindowWidth", value); }
        }

        public String MainWindowHeight
        {
            get { return Data.GetValue("MainWindowHeight", "765"); }
            set { Data.SetValue("MainWindowHeight", value); }
        }

        public String MainWindowLeft
        {
            get { return Data.GetValue("MainWindowLeft", "50"); }
            set { Data.SetValue("MainWindowLeft", value); }
        }

        public String MainWindowTop
        {
            get { return Data.GetValue("MainWindowTop", "50"); }
            set { Data.SetValue("MainWindowTop", value); }
        }

        public String GpgPath
        {
            get
            {
                String gpgPath = Data.GetValue("GpgPath", null);
                if (gpgPath != null)
                    return gpgPath;

                gpgPath = Utils.FindGpgPath();
                return gpgPath;
            }
        }

        public Boolean KeepOpenOnCommandLine
        {
            get { return false; }
        }

        #endregion Properties

        #region Config

        public event PropertyChangedEventHandler PropertyChanged;

        private static readonly ConfigData Data = new ConfigData();
        public static readonly Config Instance = new Config();

        private Config()
        {
            Data.ConfigDataChanged += DataChanged;
        }

        private void DataChanged(Object sender, String e)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(e));
        }
        
        #endregion Config
    }
}
